﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dbPoll_Application.ViewModels.ParticipantFieldViewModel>" %>

<div style="overflow:auto;max-height:640px">
<table class="questions">
<thead>
        <tr>
        <th>Group</th>
            <% int i = 0;
               foreach (var field in Model.poll.participantFields)
               {%>
                <th>
                    <%=field.name%>
                </th><%
                i++;
                if (i>6) { break; }
               } 
               %><th>Entity</th>
               <th>Delete</th>
        </tr>
    </thead>
    <tbody>
        <% 
            foreach (var participant in Model.fieldValues)
           {
               
        %>
        <tr>
            <%  
                i = 0;
                foreach (var field in participant)
                {
                    if (field.Key.Equals("Name"))
                    {%> <td><%= Html.ActionLink(field.Value, "Details", "Participant", new { participantID = participant.ElementAt(0).Value, pollID = Model.poll.pollID }, null)%></td>
                    <%}
                    else if (field.Key!="groupID")
                    {%><td><%=field.Value%></td>
            <%}
                    i++;
                    if (i > 9) { break; }
                }%>
        <% using (Ajax.BeginForm("DeleteGroup", new 
            { groupID = participant.First().Value, pollID= Model.poll.pollID }, new AjaxOptions{UpdateTargetId = "message", OnSuccess="deleted"}))
           { %>
                    <% Html.ValidationSummary(true); %>
                    <td><input type="submit" value="Delete" /></td></tr>
                <%}
        %></tr>
        <% i++;
        } %>
    </tbody>
</table>
</div>